package code.remote.request {

import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.ObjectUtil;
	

public class InsertTopicRequest extends AbstractActionRequest {
	
	private static const REQUEST_TYPE: String = "insert_topic";
	
	private var isOffered: Boolean;
	private var title: String;
	private var categoryId: int;
	private var userId: int;
	
	public function InsertTopicRequest(isOffered: Boolean, title: String, categoryId: int, userId: int) {
		super(REQUEST_TYPE);
		
		this.isOffered = isOffered;
		this.title = title;
		this.categoryId = categoryId;
		this.userId = userId;
	}
	
	protected final override function getXmlData(): String {
		const topicTag: String = this.isOffered ? 'OfferedTopic' : 'NeededTopic';
		
		return "<Request><"+topicTag+">" +
					"<User><UserId>"+userId+"</UserId></User>" + 
					"<Title>"+this.title+"</Title>" +
					"<CategoryId>"+this.categoryId+"</CategoryId>" +
				"</"+topicTag+"></Request>"
	}
	
}
}